package com.xxxx.server.controller;

import com.xxxx.server.pojo.*;
import com.xxxx.server.service.impl.EmployeeSalaryServiceIml;
import com.xxxx.server.service.impl.SalaryServiceImpl;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 员工账套模块
 */
@RestController
@RequestMapping("/salary/sobcfg")
public class EmployeeSalaryController {
    @Autowired
    private SalaryServiceImpl salaryService;
    @Resource
    private EmployeeSalaryServiceIml employeeSalaryServiceIml;

    /**
     * 分页查询员工账套数据
     * @param currentPage
     * @param size
     * @return
     */
    @GetMapping("/")
    @ApiOperation(value = "查询员工账套+分页")
    public Map<String, Object> selectSalaryEmployee(@RequestParam(defaultValue = "1") Integer currentPage, @RequestParam(defaultValue = "10") Integer size) {
        
        return employeeSalaryServiceIml.selectSalaryEmployeePage(currentPage,size);

    }

    /**
     * 返回修改工资账套需要修改的数据
     * @return
     */
    @GetMapping("/salaries")
    @ApiOperation(value = "查询工资账套")
    public List<Salary> selectSalaryEmployee() {
        return salaryService.list();
    }

    /**
     *修改更新员工账套所属工资账套
     * @param eid
     * @return
     */
    @PutMapping("/")
    @ApiOperation(value = "更新员工账套所属工资账套")
    public RespBean updateSalaryEmployee(Integer eid,Integer sid) {
        //返回更新记录条数
        if (employeeSalaryServiceIml.updateSalaryEmployee(eid,sid) == 1) {
            return RespBean.success("修改成功！");
        }
        return RespBean.error("修改失败！");
    }
}
